using System;
using System.Data;
using System.Data.OleDb;
using System.Collections;
using System.Configuration;
using System.Runtime.InteropServices;

//Using PCS's namespaces
using PCSComUtils.DataAccess;
using PCSComUtils.PCSExc;
using PCSComUtils.Common;

namespace PCSComProduction.ScrapRecording.DS
{
	public class PRO_AOScrapCostDS //: PCSComUtils.Generic.IObjectDS 
	{
		public PRO_AOScrapCostDS()
		{
		}
		private const string THIS = "PCSComProduction.ScrapRecording.DS.PRO_AOScrapCostDS";

	
		///    <summary>
		///       This method uses to add data to PRO_AOScrapCost
		///    </summary>
		///    <Inputs>
		///        PRO_AOScrapCostVO       
		///    </Inputs>
		///    <Returns>
		///       void
		///    </Returns>
		///    <History>
		///       Tuesday, June 07, 2005
		///    </History>


		public void Add(object pobjObjectVO)
		{
			const string METHOD_NAME = THIS + ".Add()";
			 
			OleDbConnection oconPCS = null;
			OleDbCommand ocmdPCS = null;

			try
			{
				PRO_AOScrapCostVO objObject = (PRO_AOScrapCostVO) pobjObjectVO;
				
				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);				
				
				string strSql = "INSERT INTO PRO_AOScrapCost("
					+ PRO_AOScrapCostTable.UNITCOST01_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST02_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST03_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST04_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST05_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST06_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST07_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST08_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST09_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST10_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST11_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST12_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST13_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST14_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST15_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST16_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST17_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST18_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST19_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST20_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST21_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST01_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST02_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST03_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST04_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST05_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST06_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST07_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST08_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST09_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST10_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST11_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST12_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST13_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST14_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST15_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST16_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST17_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST18_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST19_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST20_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST21_FLD + ","
					+ PRO_AOScrapCostTable.AOSCRAPDETAILID_FLD + ")"
					+ " VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";

				strSql += "; SELECT @@Identity as NewID";

				ocmdPCS = new OleDbCommand(strSql, oconPCS);
				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST01_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST01_FLD].Value = objObject.UnitCost01;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST02_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST02_FLD].Value = objObject.UnitCost02;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST03_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST03_FLD].Value = objObject.UnitCost03;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST04_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST04_FLD].Value = objObject.UnitCost04;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST05_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST05_FLD].Value = objObject.UnitCost05;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST06_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST06_FLD].Value = objObject.UnitCost06;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST07_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST07_FLD].Value = objObject.UnitCost07;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST08_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST08_FLD].Value = objObject.UnitCost08;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST09_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST09_FLD].Value = objObject.UnitCost09;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST10_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST10_FLD].Value = objObject.UnitCost10;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST11_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST11_FLD].Value = objObject.UnitCost11;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST12_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST12_FLD].Value = objObject.UnitCost12;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST13_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST13_FLD].Value = objObject.UnitCost13;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST14_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST14_FLD].Value = objObject.UnitCost14;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST15_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST15_FLD].Value = objObject.UnitCost15;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST16_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST16_FLD].Value = objObject.UnitCost16;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST17_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST17_FLD].Value = objObject.UnitCost17;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST18_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST18_FLD].Value = objObject.UnitCost18;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST19_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST19_FLD].Value = objObject.UnitCost19;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST20_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST20_FLD].Value = objObject.UnitCost20;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST21_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST21_FLD].Value = objObject.UnitCost21;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST01_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST01_FLD].Value = objObject.AOCost01;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST02_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST02_FLD].Value = objObject.AOCost02;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST03_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST03_FLD].Value = objObject.AOCost03;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST04_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST04_FLD].Value = objObject.AOCost04;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST05_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST05_FLD].Value = objObject.AOCost05;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST06_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST06_FLD].Value = objObject.AOCost06;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST07_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST07_FLD].Value = objObject.AOCost07;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST08_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST08_FLD].Value = objObject.AOCost08;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST09_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST09_FLD].Value = objObject.AOCost09;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST10_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST10_FLD].Value = objObject.AOCost10;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST11_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST11_FLD].Value = objObject.AOCost11;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST12_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST12_FLD].Value = objObject.AOCost12;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST13_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST13_FLD].Value = objObject.AOCost13;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST14_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST14_FLD].Value = objObject.AOCost14;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST15_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST15_FLD].Value = objObject.AOCost15;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST16_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST16_FLD].Value = objObject.AOCost16;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST17_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST17_FLD].Value = objObject.AOCost17;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST18_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST18_FLD].Value = objObject.AOCost18;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST19_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST19_FLD].Value = objObject.AOCost19;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST20_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST20_FLD].Value = objObject.AOCost20;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST21_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST21_FLD].Value = objObject.AOCost21;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOSCRAPDETAILID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOSCRAPDETAILID_FLD].Value = objObject.AOScrapDetailID;

				ocmdPCS.Connection.Open();
				int intNewID = int.Parse(ocmdPCS.ExecuteScalar().ToString());
				objObject.AOScrapCostID = intNewID;
			}
			catch(OleDbException ex)
			{
				if (ex.Errors[1].NativeError == ErrorCode.SQLDUPLICATE_KEYCODE)
				{																   
					throw new PCSDBException(ErrorCode.DUPLICATE_KEY, METHOD_NAME, ex);				
				}
				else
				{
					throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
				}
			}
			catch(InvalidOperationException ex)
			{
				throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
			}
			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}
			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}
		}	

		///    <summary>
		///       This method uses to add data to PRO_AOScrapCost
		///    </summary>
		///    <Inputs>
		///        PRO_AOScrapCostVO       
		///    </Inputs>
		///    <Returns>
		///       void
		///    </Returns>
		///    <History>
		///       Tuesday, June 07, 2005
		///    </History>

		public void Delete(int pintID)
		{
			const string METHOD_NAME = THIS + ".Delete()";
			string strSql = "DELETE " + PRO_AOScrapCostTable.TABLE_NAME + " WHERE  " + PRO_AOScrapCostTable.AOSCRAPCOSTID_FLD + "=" + pintID.ToString();
			
			OleDbConnection oconPCS = null;
			OleDbCommand ocmdPCS = null;
			
			try
			{
				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				ocmdPCS = new OleDbCommand(strSql, oconPCS);

				ocmdPCS.Connection.Open();
				ocmdPCS.ExecuteNonQuery();	
				ocmdPCS = null;
			}
			catch(OleDbException ex)
			{
				if (ex.Errors[1].NativeError == ErrorCode.SQLCASCADE_PREVENT_KEYCODE)
				{																   
					throw new PCSDBException(ErrorCode.CASCADE_DELETE_PREVENT, METHOD_NAME, ex);				
				}
				else
				{
					throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
				}
			}
			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}
			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}
		}
	

		///    <summary>
		///       This method uses to add data to PRO_AOScrapCost
		///    </summary>
		///    <Inputs>
		///        PRO_AOScrapCostVO       
		///    </Inputs>
		///    <Returns>
		///       void
		///    </Returns>
		///    <History>
		///       Tuesday, June 07, 2005
		///    </History>

		public object GetObjectVO(int pintAOScrapDetailID)
		{
			const string METHOD_NAME = THIS + ".GetObjectVO()";
			DataSet dstPCS = new DataSet();
			
			OleDbDataReader odrPCS = null;
			OleDbConnection oconPCS = null;
			OleDbCommand ocmdPCS = null;
			try 
			{
				string strSql = "SELECT "
					+ PRO_AOScrapCostTable.AOSCRAPCOSTID_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST01_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST02_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST03_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST04_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST05_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST06_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST07_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST08_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST09_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST10_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST11_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST12_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST13_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST14_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST15_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST16_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST17_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST18_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST19_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST20_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST21_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST01_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST02_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST03_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST04_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST05_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST06_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST07_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST08_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST09_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST10_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST11_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST12_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST13_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST14_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST15_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST16_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST17_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST18_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST19_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST20_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST21_FLD + ","
					+ PRO_AOScrapCostTable.AOSCRAPDETAILID_FLD
					+ " FROM " + PRO_AOScrapCostTable.TABLE_NAME
					+ " WHERE " + PRO_AOScrapCostTable.AOSCRAPDETAILID_FLD + "=" + pintAOScrapDetailID;

				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				ocmdPCS = new OleDbCommand(strSql, oconPCS);

				ocmdPCS.Connection.Open();
				odrPCS = ocmdPCS.ExecuteReader();
			

				if(odrPCS.Read())
				{ 
					PRO_AOScrapCostVO objObject = new PRO_AOScrapCostVO();

					objObject.AOScrapCostID = int.Parse(odrPCS[PRO_AOScrapCostTable.AOSCRAPCOSTID_FLD].ToString().Trim());
					objObject.UnitCost01 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.UNITCOST01_FLD].ToString().Trim());
					objObject.UnitCost02 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.UNITCOST02_FLD].ToString().Trim());
					objObject.UnitCost03 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.UNITCOST03_FLD].ToString().Trim());
					objObject.UnitCost04 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.UNITCOST04_FLD].ToString().Trim());
					objObject.UnitCost05 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.UNITCOST05_FLD].ToString().Trim());
					objObject.UnitCost06 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.UNITCOST06_FLD].ToString().Trim());
					objObject.UnitCost07 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.UNITCOST07_FLD].ToString().Trim());
					objObject.UnitCost08 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.UNITCOST08_FLD].ToString().Trim());
					objObject.UnitCost09 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.UNITCOST09_FLD].ToString().Trim());
					objObject.UnitCost10 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.UNITCOST10_FLD].ToString().Trim());
					objObject.UnitCost11 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.UNITCOST11_FLD].ToString().Trim());
					objObject.UnitCost12 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.UNITCOST12_FLD].ToString().Trim());
					objObject.UnitCost13 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.UNITCOST13_FLD].ToString().Trim());
					objObject.UnitCost14 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.UNITCOST14_FLD].ToString().Trim());
					objObject.UnitCost15 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.UNITCOST15_FLD].ToString().Trim());
					objObject.UnitCost16 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.UNITCOST16_FLD].ToString().Trim());
					objObject.UnitCost17 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.UNITCOST17_FLD].ToString().Trim());
					objObject.UnitCost18 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.UNITCOST18_FLD].ToString().Trim());
					objObject.UnitCost19 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.UNITCOST19_FLD].ToString().Trim());
					objObject.UnitCost20 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.UNITCOST20_FLD].ToString().Trim());
					objObject.UnitCost21 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.UNITCOST21_FLD].ToString().Trim());
					objObject.AOCost01 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.AOCOST01_FLD].ToString().Trim());
					objObject.AOCost02 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.AOCOST02_FLD].ToString().Trim());
					objObject.AOCost03 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.AOCOST03_FLD].ToString().Trim());
					objObject.AOCost04 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.AOCOST04_FLD].ToString().Trim());
					objObject.AOCost05 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.AOCOST05_FLD].ToString().Trim());
					objObject.AOCost06 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.AOCOST06_FLD].ToString().Trim());
					objObject.AOCost07 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.AOCOST07_FLD].ToString().Trim());
					objObject.AOCost08 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.AOCOST08_FLD].ToString().Trim());
					objObject.AOCost09 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.AOCOST09_FLD].ToString().Trim());
					objObject.AOCost10 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.AOCOST10_FLD].ToString().Trim());
					objObject.AOCost11 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.AOCOST11_FLD].ToString().Trim());
					objObject.AOCost12 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.AOCOST12_FLD].ToString().Trim());
					objObject.AOCost13 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.AOCOST13_FLD].ToString().Trim());
					objObject.AOCost14 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.AOCOST14_FLD].ToString().Trim());
					objObject.AOCost15 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.AOCOST15_FLD].ToString().Trim());
					objObject.AOCost16 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.AOCOST16_FLD].ToString().Trim());
					objObject.AOCost17 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.AOCOST17_FLD].ToString().Trim());
					objObject.AOCost18 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.AOCOST18_FLD].ToString().Trim());
					objObject.AOCost19 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.AOCOST19_FLD].ToString().Trim());
					objObject.AOCost20 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.AOCOST20_FLD].ToString().Trim());
					objObject.AOCost21 = Decimal.Parse(odrPCS[PRO_AOScrapCostTable.AOCOST21_FLD].ToString().Trim());
					objObject.AOScrapDetailID = int.Parse(odrPCS[PRO_AOScrapCostTable.AOSCRAPDETAILID_FLD].ToString().Trim());

					return objObject;
				}
				else
				{
					return null;
				}
				
				
			}
			catch(OleDbException ex)
			{			
				throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
			}			

			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}

			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}
		}

		
		///    <summary>
		///       This method uses to add data to PRO_AOScrapCost
		///    </summary>
		///    <Inputs>
		///        PRO_AOScrapCostVO       
		///    </Inputs>
		///    <Returns>
		///       void
		///    </Returns>
		///    <History>
		///       Tuesday, June 07, 2005
		///    </History>

		public DataRow GetAOScrapCost(int pintAOScrapDetailId)
		{
			const string METHOD_NAME = THIS + ".GetObjectVO()";
			DataSet dstPCS = new DataSet();
			
			OleDbDataReader odrPCS = null;
			OleDbConnection oconPCS = null;
			OleDbCommand ocmdPCS = null;
			try 
			{
				string strSql = "SELECT "
					+ PRO_AOScrapCostTable.AOSCRAPCOSTID_FLD + ", "
					+ PRO_AOScrapCostTable.UNITCOST01_FLD + ", "
					+ PRO_AOScrapCostTable.UNITCOST02_FLD + ", "
					+ PRO_AOScrapCostTable.UNITCOST03_FLD + ", "
					+ PRO_AOScrapCostTable.UNITCOST04_FLD + ", "
					+ PRO_AOScrapCostTable.UNITCOST05_FLD + ", "
					+ PRO_AOScrapCostTable.UNITCOST06_FLD + ", "
					+ PRO_AOScrapCostTable.UNITCOST07_FLD + ", "
					+ PRO_AOScrapCostTable.UNITCOST08_FLD + ", "
					+ PRO_AOScrapCostTable.UNITCOST09_FLD + ", "
					+ PRO_AOScrapCostTable.UNITCOST10_FLD + ", "
					+ PRO_AOScrapCostTable.UNITCOST11_FLD + ", "
					+ PRO_AOScrapCostTable.UNITCOST12_FLD + ", "
					+ PRO_AOScrapCostTable.UNITCOST13_FLD + ", "
					+ PRO_AOScrapCostTable.UNITCOST14_FLD + ", "
					+ PRO_AOScrapCostTable.UNITCOST15_FLD + ", "
					+ PRO_AOScrapCostTable.UNITCOST16_FLD + ", "
					+ PRO_AOScrapCostTable.UNITCOST17_FLD + ", "
					+ PRO_AOScrapCostTable.UNITCOST18_FLD + ", "
					+ PRO_AOScrapCostTable.UNITCOST19_FLD + ", "
					+ PRO_AOScrapCostTable.UNITCOST20_FLD + ", "
					+ PRO_AOScrapCostTable.UNITCOST21_FLD + ", "
					+ PRO_AOScrapCostTable.AOCOST01_FLD + ", "
					+ PRO_AOScrapCostTable.AOCOST02_FLD + ", "
					+ PRO_AOScrapCostTable.AOCOST03_FLD + ", "
					+ PRO_AOScrapCostTable.AOCOST04_FLD + ", "
					+ PRO_AOScrapCostTable.AOCOST05_FLD + ", "
					+ PRO_AOScrapCostTable.AOCOST06_FLD + ", "
					+ PRO_AOScrapCostTable.AOCOST07_FLD + ", "
					+ PRO_AOScrapCostTable.AOCOST08_FLD + ", "
					+ PRO_AOScrapCostTable.AOCOST09_FLD + ", "
					+ PRO_AOScrapCostTable.AOCOST10_FLD + ", "
					+ PRO_AOScrapCostTable.AOCOST11_FLD + ", "
					+ PRO_AOScrapCostTable.AOCOST12_FLD + ", "
					+ PRO_AOScrapCostTable.AOCOST13_FLD + ", "
					+ PRO_AOScrapCostTable.AOCOST14_FLD + ", "
					+ PRO_AOScrapCostTable.AOCOST15_FLD + ", "
					+ PRO_AOScrapCostTable.AOCOST16_FLD + ", "
					+ PRO_AOScrapCostTable.AOCOST17_FLD + ", "
					+ PRO_AOScrapCostTable.AOCOST18_FLD + ", "
					+ PRO_AOScrapCostTable.AOCOST19_FLD + ", "
					+ PRO_AOScrapCostTable.AOCOST20_FLD + ", "
					+ PRO_AOScrapCostTable.AOCOST21_FLD + ", "
					+ PRO_AOScrapCostTable.AOSCRAPDETAILID_FLD
					+ " FROM " + PRO_AOScrapCostTable.TABLE_NAME
					+ " WHERE " + PRO_AOScrapCostTable.AOSCRAPDETAILID_FLD + "=" + pintAOScrapDetailId;

				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				ocmdPCS = new OleDbCommand(strSql, oconPCS);

				ocmdPCS.Connection.Open();
				odrPCS = ocmdPCS.ExecuteReader();

				DataSet dstAOScrapCost = new DataSet();		
				OleDbDataAdapter odadPCS = new OleDbDataAdapter(ocmdPCS);
				odadPCS.Fill(dstAOScrapCost, PRO_AOScrapCostTable.TABLE_NAME);

				if(dstAOScrapCost.Tables[PRO_AOScrapCostTable.TABLE_NAME].Rows.Count != 0)
				{
					return dstAOScrapCost.Tables[PRO_AOScrapCostTable.TABLE_NAME].Rows[0];
				}
				else
				{
					return null;
				}
				
			}
			catch(OleDbException ex)
			{			
				throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
			}			

			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}

			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}
		}

		///    <summary>
		///       This method uses to add data to PRO_AOScrapCost
		///    </summary>
		///    <Inputs>
		///        PRO_AOScrapCostVO       
		///    </Inputs>
		///    <Returns>
		///       void
		///    </Returns>
		///    <History>
		///       Tuesday, June 07, 2005
		///    </History>
		
	
		public void Update(object pobjObjecVO)
		{
			const string METHOD_NAME = THIS + ".Update()";

			PRO_AOScrapCostVO objObject = (PRO_AOScrapCostVO) pobjObjecVO;
			
			//prepare value for parameters
			OleDbConnection oconPCS =null;
			OleDbCommand ocmdPCS = null;
			try 
			{				
				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				
				string strSql = "UPDATE PRO_AOScrapCost SET "
					+ PRO_AOScrapCostTable.UNITCOST01_FLD + "=?, "
					+ PRO_AOScrapCostTable.UNITCOST02_FLD + "=?, "
					+ PRO_AOScrapCostTable.UNITCOST03_FLD + "=?, "
					+ PRO_AOScrapCostTable.UNITCOST04_FLD + "=?, "
					+ PRO_AOScrapCostTable.UNITCOST05_FLD + "=?, "
					+ PRO_AOScrapCostTable.UNITCOST06_FLD + "=?, "
					+ PRO_AOScrapCostTable.UNITCOST07_FLD + "=?, "
					+ PRO_AOScrapCostTable.UNITCOST08_FLD + "=?, "
					+ PRO_AOScrapCostTable.UNITCOST09_FLD + "=?, "
					+ PRO_AOScrapCostTable.UNITCOST10_FLD + "=?, "
					+ PRO_AOScrapCostTable.UNITCOST11_FLD + "=?, "
					+ PRO_AOScrapCostTable.UNITCOST12_FLD + "=?, "
					+ PRO_AOScrapCostTable.UNITCOST13_FLD + "=?, "
					+ PRO_AOScrapCostTable.UNITCOST14_FLD + "=?, "
					+ PRO_AOScrapCostTable.UNITCOST15_FLD + "=?, "
					+ PRO_AOScrapCostTable.UNITCOST16_FLD + "=?, "
					+ PRO_AOScrapCostTable.UNITCOST17_FLD + "=?, "
					+ PRO_AOScrapCostTable.UNITCOST18_FLD + "=?, "
					+ PRO_AOScrapCostTable.UNITCOST19_FLD + "=?, "
					+ PRO_AOScrapCostTable.UNITCOST20_FLD + "=?, "
					+ PRO_AOScrapCostTable.UNITCOST21_FLD + "=?, "
					+ PRO_AOScrapCostTable.AOCOST01_FLD + "=?, "
					+ PRO_AOScrapCostTable.AOCOST02_FLD + "=?, "
					+ PRO_AOScrapCostTable.AOCOST03_FLD + "=?, "
					+ PRO_AOScrapCostTable.AOCOST04_FLD + "=?, "
					+ PRO_AOScrapCostTable.AOCOST05_FLD + "=?, "
					+ PRO_AOScrapCostTable.AOCOST06_FLD + "=?, "
					+ PRO_AOScrapCostTable.AOCOST07_FLD + "=?, "
					+ PRO_AOScrapCostTable.AOCOST08_FLD + "=?, "
					+ PRO_AOScrapCostTable.AOCOST09_FLD + "=?, "
					+ PRO_AOScrapCostTable.AOCOST10_FLD + "=?, "
					+ PRO_AOScrapCostTable.AOCOST11_FLD + "=?, "
					+ PRO_AOScrapCostTable.AOCOST12_FLD + "=?, "
					+ PRO_AOScrapCostTable.AOCOST13_FLD + "=?, "
					+ PRO_AOScrapCostTable.AOCOST14_FLD + "=?, "
					+ PRO_AOScrapCostTable.AOCOST15_FLD + "=?, "
					+ PRO_AOScrapCostTable.AOCOST16_FLD + "=?, "
					+ PRO_AOScrapCostTable.AOCOST17_FLD + "=?, "
					+ PRO_AOScrapCostTable.AOCOST18_FLD + "=?, "
					+ PRO_AOScrapCostTable.AOCOST19_FLD + "=?, "
					+ PRO_AOScrapCostTable.AOCOST20_FLD + "=?, "
					+ PRO_AOScrapCostTable.AOCOST21_FLD + "=?, "
					+ PRO_AOScrapCostTable.AOSCRAPDETAILID_FLD + "=?"
					+ " WHERE " + PRO_AOScrapCostTable.AOSCRAPCOSTID_FLD + "=?";
				
				ocmdPCS = new OleDbCommand(strSql, oconPCS);
				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST01_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST01_FLD].Value = objObject.UnitCost01;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST02_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST02_FLD].Value = objObject.UnitCost02;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST03_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST03_FLD].Value = objObject.UnitCost03;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST04_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST04_FLD].Value = objObject.UnitCost04;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST05_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST05_FLD].Value = objObject.UnitCost05;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST06_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST06_FLD].Value = objObject.UnitCost06;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST07_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST07_FLD].Value = objObject.UnitCost07;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST08_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST08_FLD].Value = objObject.UnitCost08;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST09_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST09_FLD].Value = objObject.UnitCost09;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST10_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST10_FLD].Value = objObject.UnitCost10;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST11_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST11_FLD].Value = objObject.UnitCost11;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST12_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST12_FLD].Value = objObject.UnitCost12;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST13_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST13_FLD].Value = objObject.UnitCost13;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST14_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST14_FLD].Value = objObject.UnitCost14;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST15_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST15_FLD].Value = objObject.UnitCost15;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST16_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST16_FLD].Value = objObject.UnitCost16;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST17_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST17_FLD].Value = objObject.UnitCost17;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST18_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST18_FLD].Value = objObject.UnitCost18;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST19_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST19_FLD].Value = objObject.UnitCost19;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST20_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST20_FLD].Value = objObject.UnitCost20;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.UNITCOST21_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.UNITCOST21_FLD].Value = objObject.UnitCost21;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST01_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST01_FLD].Value = objObject.AOCost01;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST02_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST02_FLD].Value = objObject.AOCost02;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST03_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST03_FLD].Value = objObject.AOCost03;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST04_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST04_FLD].Value = objObject.AOCost04;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST05_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST05_FLD].Value = objObject.AOCost05;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST06_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST06_FLD].Value = objObject.AOCost06;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST07_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST07_FLD].Value = objObject.AOCost07;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST08_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST08_FLD].Value = objObject.AOCost08;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST09_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST09_FLD].Value = objObject.AOCost09;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST10_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST10_FLD].Value = objObject.AOCost10;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST11_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST11_FLD].Value = objObject.AOCost11;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST12_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST12_FLD].Value = objObject.AOCost12;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST13_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST13_FLD].Value = objObject.AOCost13;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST14_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST14_FLD].Value = objObject.AOCost14;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST15_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST15_FLD].Value = objObject.AOCost15;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST16_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST16_FLD].Value = objObject.AOCost16;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST17_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST17_FLD].Value = objObject.AOCost17;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST18_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST18_FLD].Value = objObject.AOCost18;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST19_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST19_FLD].Value = objObject.AOCost19;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST20_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST20_FLD].Value = objObject.AOCost20;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOCOST21_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOCOST21_FLD].Value = objObject.AOCost21;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOSCRAPDETAILID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOSCRAPDETAILID_FLD].Value = objObject.AOScrapDetailID;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_AOScrapCostTable.AOSCRAPCOSTID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[PRO_AOScrapCostTable.AOSCRAPCOSTID_FLD].Value = objObject.AOScrapCostID;
		
				ocmdPCS.Connection.Open();
				ocmdPCS.ExecuteNonQuery();	
			}
			catch(OleDbException ex)
			{
				if (ex.Errors[1].NativeError == ErrorCode.SQLDUPLICATE_KEYCODE)
				{																   
					throw new PCSDBException(ErrorCode.DUPLICATE_KEY, METHOD_NAME, ex);				
				}
				else
				{
					throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
				}
			}
			catch(InvalidOperationException ex)
			{
				throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
			}
			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}
			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}
		}

		///    <summary>
		///       This method uses to add data to PRO_AOScrapCost
		///    </summary>
		///    <Inputs>
		///        PRO_AOScrapCostVO       
		///    </Inputs>
		///    <Returns>
		///       void
		///    </Returns>
		///    <History>
		///       Tuesday, June 07, 2005
		///    </History>

		public DataSet List()
		{
			const string METHOD_NAME = THIS + ".List()";
			DataSet dstPCS = new DataSet();

			OleDbConnection oconPCS =null;
			OleDbCommand ocmdPCS = null;
			try 
			{
				string strSql = "SELECT "
					+ PRO_AOScrapCostTable.AOSCRAPCOSTID_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST01_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST02_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST03_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST04_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST05_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST06_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST07_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST08_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST09_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST10_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST11_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST12_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST13_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST14_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST15_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST16_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST17_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST18_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST19_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST20_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST21_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST01_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST02_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST03_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST04_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST05_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST06_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST07_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST08_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST09_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST10_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST11_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST12_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST13_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST14_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST15_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST16_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST17_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST18_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST19_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST20_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST21_FLD + ","
					+ PRO_AOScrapCostTable.AOSCRAPDETAILID_FLD
					+ " FROM " + PRO_AOScrapCostTable.TABLE_NAME;

				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				ocmdPCS = new OleDbCommand(strSql, oconPCS);
				ocmdPCS.Connection.Open();
				
				OleDbDataAdapter odadPCS = new OleDbDataAdapter(ocmdPCS);
				odadPCS.Fill(dstPCS,PRO_AOScrapCostTable.TABLE_NAME);

				return dstPCS;
			}
			catch(OleDbException ex)
			{
				throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
			}			
			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}
			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}
		}

		///    <summary>
		///       This method uses to add data to PRO_AOScrapCost
		///    </summary>
		///    <Inputs>
		///        PRO_AOScrapCostVO       
		///    </Inputs>
		///    <Returns>
		///       void
		///    </Returns>
		///    <History>
		///       Tuesday, June 07, 2005
		///    </History>
		
		public void UpdateDataSet(DataSet pData)
		{
			const string METHOD_NAME = THIS + ".UpdateDataSet()";
			
			OleDbConnection oconPCS =null;
			OleDbCommandBuilder odcbPCS ;
			OleDbDataAdapter odadPCS = new OleDbDataAdapter();

			try
			{
				string strSql =	"SELECT "
					+ PRO_AOScrapCostTable.AOSCRAPCOSTID_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST01_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST02_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST03_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST04_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST05_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST06_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST07_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST08_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST09_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST10_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST11_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST12_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST13_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST14_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST15_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST16_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST17_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST18_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST19_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST20_FLD + ","
					+ PRO_AOScrapCostTable.UNITCOST21_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST01_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST02_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST03_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST04_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST05_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST06_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST07_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST08_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST09_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST10_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST11_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST12_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST13_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST14_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST15_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST16_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST17_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST18_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST19_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST20_FLD + ","
					+ PRO_AOScrapCostTable.AOCOST21_FLD + ","
					+ PRO_AOScrapCostTable.AOSCRAPDETAILID_FLD 
					+ "  FROM " + PRO_AOScrapCostTable.TABLE_NAME;

				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				odadPCS.SelectCommand = new OleDbCommand(strSql, oconPCS);
				odcbPCS = new OleDbCommandBuilder(odadPCS);
				pData.EnforceConstraints = false;
				odadPCS.Update(pData,PRO_AOScrapCostTable.TABLE_NAME);

			}
			catch(OleDbException ex)
			{
				if (ex.Errors[1].NativeError == ErrorCode.SQLDUPLICATE_KEYCODE)
				{																   
					throw new PCSDBException(ErrorCode.DUPLICATE_KEY, METHOD_NAME, ex);				
				}
				else if (ex.Errors[1].NativeError == ErrorCode.SQLCASCADE_PREVENT_KEYCODE)
				{
					throw new PCSDBException(ErrorCode.CASCADE_DELETE_PREVENT, METHOD_NAME, ex);				
				}				
				else
				{
					throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
				}
			}
			catch(InvalidOperationException ex)
			{
				throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
			}
			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}
			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}
		}

		/// <summary>
		/// Delele multi AOScrapDetailIDs 
		/// (DELETE FROM PRO_AOScrapCost WHERE AOScrapDetailID IN pobjAOScrapDetailID)		
		/// </summary>		
		public void Delete(System.Collections.Hashtable pobjAOScrapDetailID)
		{			
			const string METHOD_NAME = THIS + ".Delete()";
			if (pobjAOScrapDetailID == null) return;
			
			OleDbConnection oconPCS = null;
			try
			{
				string strIDs = string.Empty;

				IDictionaryEnumerator myEnumerator = pobjAOScrapDetailID.GetEnumerator();
				while(myEnumerator.MoveNext())
				{
					strIDs += myEnumerator.Value + ", ";
				}

				strIDs = strIDs.Substring(0, strIDs.Length - 2);

				string strSql = "DELETE " + PRO_AOScrapCostTable.TABLE_NAME + " WHERE  " + PRO_AOScrapCostTable.AOSCRAPDETAILID_FLD + " IN (" + strIDs + ")";
				

				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				OleDbCommand ocmdPCS = new OleDbCommand(strSql, oconPCS);
			
				ocmdPCS.Connection.Open();
				ocmdPCS.ExecuteNonQuery();	
				ocmdPCS = null;
			}
			catch(OleDbException ex)
			{
				if (ex.Errors[1].NativeError == ErrorCode.SQLCASCADE_PREVENT_KEYCODE)
				{																   
					throw new PCSDBException(ErrorCode.CASCADE_DELETE_PREVENT, METHOD_NAME, ex);				
				}
				else
				{
					throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
				}
			}
			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}
			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}

		}
	}
}
